package com.sunwayworld.basemodule.samplemanage.sample.resource.impl;

import com.alibaba.fastjson.JSONObject;
import com.sunwayworld.basemodule.samplemanage.sample.bean.BatchSampleStaticsDTO;
import com.sunwayworld.basemodule.samplemanage.sample.bean.LimsSampleBean;
import com.sunwayworld.framework.data.page.Page;
import com.sunwayworld.framework.mybatis.mapper.MatchPattern;
import com.sunwayworld.framework.mybatis.mapper.SearchFilter;
import com.sunwayworld.framework.restful.data.RestValidationResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.sunwayworld.basemodule.samplemanage.sample.resource.LimsSampleResource;
import com.sunwayworld.basemodule.samplemanage.sample.service.LimsSampleService;
import com.sunwayworld.framework.spring.annotation.GikamBean;
import com.sunwayworld.framework.log.annotation.Log;
import com.sunwayworld.framework.log.annotation.LogModule;
import com.sunwayworld.framework.log.annotation.LogType;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

import java.util.List;

@LogModule("样本表")
@RestController
@GikamBean
public class LimsSampleResourceImpl implements LimsSampleResource {

    @Autowired
    private LimsSampleService limsSampleService;

    @Override
    public LimsSampleService getService() {
        return limsSampleService;
    }

    @Log(value = "新增样本表", type = LogType.INSERT)
    @Override
    @RequestMapping(method = RequestMethod.POST)
    public Long insert(RestJsonWrapperBean wrapper) {
        return getService().insert(wrapper);
    }

    @Log(value = "返样", type = LogType.INSERT)
    @Override
    public void back(RestJsonWrapperBean wrapperBean) {
        getService().back(wrapperBean);
    }

    @Log(value = "销毁", type = LogType.INSERT)
    @Override
    public void destroy(RestJsonWrapperBean wrapperBean) {
        getService().destroy(wrapperBean);
    }

    @Override
    public Page<LimsSampleBean> selectHandleSample(Long handleId, RestJsonWrapperBean wrapper) {
        return getService().selectHandleSample(handleId, wrapper);
    }

    @Override
    public Long scanCodeCheck(RestJsonWrapperBean wrapper) {
        return getService().scanCodeCheck(wrapper);
    }

    @Log("过期样本查询")
    @Override
    public Page<LimsSampleBean> selectExpiredSamples(RestJsonWrapperBean wrapperBean) {
        return getService().selectExpiredSamples(wrapperBean);
    }

    @Override
    public JSONObject confirmSampleExpired(RestJsonWrapperBean jsonWrapperBean) {
        return getService().confirmSampleExpired(jsonWrapperBean);
    }

    @Override
    public JSONObject editSampleMulti(RestJsonWrapperBean jsonWrapperBean) {
        return getService().editSampleMulti(jsonWrapperBean);
    }

    @Override
    public LimsSampleBean selectSampleById(Long id) {
        // 一个样本可能挂在不同订单下
        return getService().selectFirstByFilter(SearchFilter.instance().match("batchSampleId", id).filter(MatchPattern.EQ));
    }

    @Override
    public Page<LimsSampleBean> selectForFormula(RestJsonWrapperBean wrapper) {
        return getService().selectForFormula(wrapper);
    }

    @Override
    @Log(value = "通用联合查询",type = LogType.SELECT)
    public Page<LimsSampleBean> selectByParams(RestJsonWrapperBean wrapper) {
        return getService().selectByParams(wrapper);
    }

    @Override
    @Log(value = "样本标签打印")
    public Long printSampleTag(RestJsonWrapperBean wrapper) {
        return getService().printSampleTag(wrapper);
    }

    @Override
    @Log(value = "处置样本详情",type = LogType.SELECT)
    public Page<LimsSampleBean> selectSampleHandlesPagination(RestJsonWrapperBean wrapper) {
        return getService().selectSampleHandlesPagination(wrapper);
    }

    @Override
    @Log(value = "样本接收提交",type = LogType.CONTROLLER)
    public void receiveSubmit(RestJsonWrapperBean wrapperBean) {
        getService().receiveSubmit(wrapperBean);
    }

    @Override
    @Log(value = "异常处理提交",type = LogType.CONTROLLER)
    public void abnormalSubmit(RestJsonWrapperBean wrapperBean) {
        getService().abnormalSubmit(wrapperBean);
    }

    @Override
    @Log(value = "异常处理确认",type = LogType.CONTROLLER)
    public void abnormalConfirm(RestJsonWrapperBean wrapperBean) {
        getService().abnormalConfirm(wrapperBean);
    }

    @Override
    @Log(value = "批量上传附件",type = LogType.CONTROLLER)
    public JSONObject uploadAttachmentMulti(RestJsonWrapperBean jsonWrapperBean) {
        return getService().uploadAttachmentMulti(jsonWrapperBean);
    }

    @Override
    @Log(value = "物流信息查询",type = LogType.CONTROLLER)
    public JSONObject getCourierData(RestJsonWrapperBean jsonWrapperBean) {
        return getService().getCourierData(jsonWrapperBean);
    }

    @Override
    public List<BatchSampleStaticsDTO> selectBatchSampleStaticsPage(String year) {
        return getService().selectBatchSampleStaticsPage(year);
    }

    @Override
    public Page<LimsSampleBean> selectTestMethodBySampleCode(RestJsonWrapperBean wrapper) {
        return getService().selectTestMethodBySampleCode(wrapper);
    }

    @Override
    public Page<LimsSampleBean> selectBatchChooseSamplePagination(RestJsonWrapperBean wrapper) {
        return getService().selectBatchChooseSamplePagination(wrapper);
    }

    @Override
    public Long print(RestJsonWrapperBean jsonWrapperBean) {
        return getService().print(jsonWrapperBean);
    }

    @Override
    public RestValidationResultBean validateGeneratedSamplecode(Long id, String columnName, String columnValue) {
        return getService().validateGeneratedSamplecode(id, columnName, columnValue);
    }

    @Override
    public Page<LimsSampleBean> selectPassRate(RestJsonWrapperBean wrapper) {
        return getService().selectPassRate(wrapper);
    }
}
